<?php
require_once('vendor/autoload.php');

$remoteHost = 'wss://ws.coincap.io/prices?assets=bitcoin';
\Ratchet\Client\connect($remoteHost)->then(function ($conn) {
    $conn->on('message', function($msg) use ($conn) {
        echo "Received: {$msg}\n";
    });
    while (true) {
        sleep(5);
        echo "ping \n";
        $conn->send('ping');
    }
}, function ($e) {
    echo "Could not connect: {$e->getMessage()}\n";
});